package com.lzy.cloud.permission.service.impl;

import com.lzy.cloud.permission.dtos.UserRoleDto;
import com.lzy.cloud.permission.entity.UserRole;
import com.lzy.cloud.permission.mapper.UserRoleMapperExt;
import com.lzy.cloud.permission.service.UserRoleService;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by WIN7 on 2018/5/17.
 */
@Service
public class UserRoleServiceImpl implements UserRoleService{

    @Autowired
    UserRoleMapperExt userRoleMapperExt;

    @Override
    public Boolean insert(UserRoleDto userRoleDto) {
        return userRoleMapperExt.insertSelective(DozerUtils.map(userRoleDto, UserRole.class))>0;
    }

    @Override
    public Boolean delete(UserRoleDto userRoleDto) {
        return userRoleMapperExt.deleteByPrimaryKey(DozerUtils.map(userRoleDto,UserRole.class))>0;
    }

    @Override
    public Boolean deleteByKey(UserRoleDto userRoleDto) {
        return userRoleMapperExt.deleteByKey(userRoleDto)>0;
    }

    @Override
    public Boolean update(UserRoleDto userRoleDto) {
        return userRoleMapperExt.updateByPrimaryKeySelective(DozerUtils.map(userRoleDto,UserRole.class))>0;
    }

    @Override
    public List<UserRoleDto> selectList(UserRoleDto userRoleDto) {
        return userRoleMapperExt.selectList(userRoleDto);
    }

    @Override
    public UserRoleDto selectUserRole(UserRoleDto userRoleDto) {
        return userRoleMapperExt.selectUserRole(userRoleDto);
    }
}
